package com.wg.wuge.study.designmodel.tulingxueyuan;

/**
 * 抽象工厂方法设计模式
 */
public class AbstractFactory {

    public static void main(String[] args) {
        databaseUtil mysqlUtil = new OracleUtil();
        mysqlUtil.command().sendCommand();
        mysqlUtil.connect().connection();
    }


}
interface connection {
    void connection();
}
interface sendCommand{
    void sendCommand();
}
interface databaseUtil {
    connection connect();
    sendCommand command();
}
class MysqlUtil implements databaseUtil {

    @Override
    public connection connect() {
        return new MysqlConnection();
    }

    @Override
    public sendCommand command() {
        return new MysqlSendCommand();
    }
}

class OracleUtil implements databaseUtil {

    @Override
    public connection connect() {
        return new OracleConnection();
    }

    @Override
    public sendCommand command() {
        return new OracleSendCommand();
    }
}

class MysqlConnection implements connection{

    @Override
    public void connection() {
        System.out.println("msyql created.");
    }
}
class MysqlSendCommand implements sendCommand{

    @Override
    public void sendCommand() {
        System.out.println("mysql send command");
    }
}

class OracleConnection implements connection{

    @Override
    public void connection() {
        System.out.println("oracle created.");
    }
}
class OracleSendCommand implements sendCommand{

    @Override
    public void sendCommand() {
        System.out.println("oracle send command");
    }
}
